履歴: 電気回路/zynq/Device Tree Overlay
各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 7 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます
| 日時 | タイトル | 文字数 | 追加 | 削除 | 内容 | 差分 | 基準 |
|---|---|---|---|---|---|---|---|
| 2017/3/3 5:33:44 | 電気回路/zynq/Device Tree Overlay 最新版 | 10,944 | +1 | -1 | 表示 | 差分 | — |
| 2017/3/3 5:33:44 | 電気回路/zynq/Device Tree Overlay | 10,950 | +1 | -2 | 表示 | 差分 | 選択 |
| 2017/3/2 20:33:44 | 電気回路/zynq/Device Tree Overlay | 10,952 | +16 | -5 | 表示 | 差分 | 選択 |
| 2017/3/2 20:33:44 | 電気回路/zynq/Device Tree Overlay | 10,678 | +5 | -6 | 表示 | 表示中 | 選択 |
| 2017/3/2 20:33:44 | 電気回路/zynq/Device Tree Overlay | 10,761 | +184 | -21 | 表示 | 差分 | 選択 |
| 2017/3/2 16:30:28 | 電気回路/zynq/Device Tree Overlay | 6,092 | +100 | -8 | 表示 | 差分 | 基準 |
| 2017/3/2 10:19:33 | 電気回路/zynq/Device Tree Overlay | 3,050 | — | — | 表示 | — | 選択 |
基準: 電気回路/zynq/Device Tree Overlay (2017/3/2 16:30:28) → 比較: 電気回路/zynq/Device Tree Overlay (2017/3/2 20:33:44)
@@ -22,25 +22,28 @@
* 情報 [#vff0dbb9]
dtc に -@ を付けて、unresolved reference を許可できる話など~
-https://www.raspberrypi.org/documentation/configuration/device-tree.md
+https://www.raspberrypi.org/documentation/configuration/device-tree.md ~
+ん? "dtc: invalid option -- '@'" となる???(Version: DTC 1.4.0)~
+
* configfs だけで使える? [#wa82a16c]
http://qiita.com/ikwzm/items/ec514e955c16076327ce
-では configfs だけで使えればいいのに、といいつつ独自の dtbocfg
+こちら↑では configfs だけで使えればいいのに、といいつつ独自の dtbocfg
を作って使っていたのですが、4.6.0-xilinx ではどうか、まず試してみました。
menuconfig の File System ---> Pseudo filesystems ---> {M} Userspace-driven configuration filesystem
で configfs を有効にして、
LANG:console
- $ sudo insmod /lib/modules/4.6.0-xilinx/kernel/fs/configfs/configfs.ko
- $ sudo mkdir /config
- $ sudo mount -t configfs none /config
- $ ls /config
- $ sudo mkdir -p /config/device-tree/overlays/test
- mkdir: cannot create directory ‘/config/device-tree’: Operation not permitted
+ $ sudo modprobe configfs
+ $ mount | grep configfs
+ configfs on /sys/kernel/config type configfs (rw,relatime)
+ $ ls /sys/kernel/config
+ /sys/kernel/config
+ $ sudo mkdir -p /sys/kernel/config/device-tree/overlays/test
+ mkdir: cannot create directory ‘/sys/kernel/config/device-tree’: Operation not permitted
どうやらまだできないようです?
@@ -50,7 +53,7 @@
http://qiita.com/ikwzm/items/ec514e955c16076327ce
-の dtbocfg を使おうと思います。
+の dtbocfg を使わせてもらうことにします。
ビルドにカーネルソースを必要とするので、PetaLinux のクロスコンパイル環境を
使ってビルドしました。
@@ -114,7 +117,7 @@
Linux xenial-zynq 4.6.0-xilinx #1 SMP PREEMPT Fri Feb 24 07:17:45 JST 2017 armv7l armv7l armv7l GNU/Linux
$ ls dtbocfg.ko
dtbocfg.ko
- $ sudo insmode dtbocfg.ko
+ $ sudo insmod dtbocfg.ko
insmod: ERROR: could not insert module dtbocfg.ko: Unknown symbol in module
$ # 肝心の symbol 名が表示されない???
$ sudo tail /var/log/kern.log
@@ -126,11 +129,10 @@
Mar 2 15:54:08 xenial-zynq kernel: dtbocfg: Unknown symbol config_item_init_type_name (err 0)
Mar 2 15:54:08 xenial-zynq kernel: dtbocfg: Unknown symbol config_item_put (err 0)
Mar 2 15:54:08 xenial-zynq kernel: dtbocfg: Unknown symbol configfs_unregister_group (err 0)
- $ sudo insmod /lib/modules/4.6.0-xilinx/kernel/fs/configfs/configfs.ko
- $ sudo insmode dtbocfg.ko
- $ sudo mount -t configfs none /config
- $ ls -d /config/device-tree/overlays
- /config/device-tree/overlays
+ $ sudo modprobe configfs
+ $ sudo insmod dtbocfg.ko
+ $ ls -d /sys/kernel/config/device-tree/overlays
+ /sys/kernel/config/device-tree/overlays
うまくいった。
@@ -148,7 +150,7 @@
__overlay__ {
#address-cells = <0x1>;
#size-cells = <0x1>;
- uio0@43c00000 {
+ accesstest@43c00000 {
compatible = "generic-uio";
reg = <0x43c00000 0x1000>;
interrupts = <0 57 0>;
@@ -157,6 +159,7 @@
};
};
};
+ ^D
$ dtc -O dtb -o accesstest-uio.dtbo accesstest-uio.dts
$ ls
accesstest-uio.dtbo accesstest-uio.dts dtbocfg.ko
@@ -164,14 +167,173 @@
* dtb の組み込み [#w4c2fbb9]
LANG:console
- $ sudo mkdir /config/device-tree/overlays/accesstest
- $ ls /config/device-tree/overlays/accesstest
+ $ sudo mkdir /sys/kernel/config/device-tree/overlays/accesstest
+ $ ls /sys/kernel/config/device-tree/overlays/accesstest
dtbo status
- $ sudo cp accesstest-uio.dtbo /config/device-tree/overlays/acesstest/dtbo
- $ sudo echo 1 > /config/device-tree/overlays/accesstest/status
- -bash: /config/device-tree/overlays/accesstest/status: Permission denied
- $ sudo bash -c "echo 1 > /config/device-tree/overlays/accesstest/status"
+ $ sudo cp accesstest-uio.dtbo /sys/kernel/config/device-tree/overlays/acesstest/dtbo
+ $ sudo echo 1 > /sys/kernel/config/device-tree/overlays/accesstest/status
+ -bash: /sys/kernel/config/device-tree/overlays/accesstest/status: Permission denied
+ $ sudo bash -c "echo 1 > /sys/kernel/config/device-tree/overlays/accesstest/status"
$ ls /dev/uio*
+ ls: cannot access '/dev/uio*': No such file or directory
$
あれ?うまくいかない。
+
+* まずは普通に組み込めるかテスト [#ia616ad7]
+
+ LANG:console
+ $ dtc -I dtb -O dts -o devicetree.dts /boot/devicetree.dtb
+ $ jed devicetree.dts
+ amba {
+ compatible = "simple-bus";
+ #address-cells = <0x1>;
+ #size-cells = <0x1>;
+ interrupt-parent = <0x3>;
+ ranges;
+
+ + accesstest@43c00000 {
+ + compatible = "generic-uio", "uio", "uio_pdrv";
+ + reg = <0x43c00000 0x1000>;
+ + interrupts = < 0 57 0 >;
+ + interrupt-parent = <0x3>;
+ + };
+ $ sudo dtc -O dtb -o /boot/devicetree.dtb devicetree.dts
+ $ sudo reboot
+ ...
+ Login: osamu
+ Password: ************
+ $ ls /dev/uio*
+ ls: cannot access '/dev/uio*': No such file or directory
+ $ grep uio /lib/modules/4.6.0-xilinx/modules.builtin
+ kernel/drivers/uio/uio.ko
+ kernel/drivers/uio/uio_pdrv_genirq.ko
+ kernel/drivers/uio/uio_xilinx_apm.ko
+ $ ls -ld /sys/class/uio/
+ drwxr-xr-x 2 root root 0 3月 2 16:50 /sys/class/uio/
+
+こっちの問題か orz
+
+カーネルドライバは入っているし、/sys には uio クラスが登録されているけれど、
+/dev/uio* が見つからない。
+
+https://forum.digilentinc.com/topic/2719-how-to-register-my-device-as-uio-on-petalinux/#comment-9553
+
+> bootargs に uio_pdrv_genirq.of_id=generic-uio を追加しないとね
+
+なんだって?
+
+ LANG:console
+ $ sudo jed /boot/uEnv.txt
+ - bootargs=console=ttyPS1,115200 root=/dev/mmcblk0p2 noinitrd rw earlyprintk rootfstype=ext4 devtmpfs.mount=0
+ + bootargs=console=ttyPS1,115200 root=/dev/mmcblk0p2 noinitrd rw earlyprintk rootfstype=ext4 devtmpfs.mount=0 uio_pdrv_genirq.of_id=generic-uio
+ $ sudo reboot
+ ...
+ Login: osamu
+ Password: *********
+ $ ls /dev/uio*
+ /dev/uio0
+
+うまく行ったけど・・・これは何のおまじないなんだぜ?
+
+ググってみると、Linux Kernel 全体との整合性のために
+最近の kernel では uio モジュールで compatible が使えなくなったため、
+その対応がこれなんだとか?~
+結局、何を言っているのかわからない。
+
+https://forums.xilinx.com/t5/Embedded-Linux/generic-UIO-broken/td-p/564259 ~
+https://github.com/Xilinx/linux-xlnx/commit/7ebd62dbc727ef343b07c01c852a15fc4d9cc9e5 ~
+
+overlay を試すため、一旦 /boot/devicetree.dtb を元に戻す。
+
+ LANG:console
+ $ jed devicetree.dts
+ amba {
+ compatible = "simple-bus";
+ #address-cells = <0x1>;
+ #size-cells = <0x1>;
+ interrupt-parent = <0x3>;
+ ranges;
+
+ - accesstest@43c00000 {
+ - compatible = "generic-uio", "uio", "uio_pdrv";
+ - reg = <0x43c00000 0x1000>;
+ - interrupts = < 0 57 0 >;
+ - interrupt-parent = <0x3>;
+ - };
+ $ sudo dtc -O dtb -o /boot/devicetree.dtb devicetree.dts
+ $ sudo reboot
+ Login: osamu
+ Password: *********
+ $ ls /dev/uio*
+ ls: cannot access '/dev/uio*': No such file or directory
+
+* うまくいった [#q4ed734b]
+
+ LANG:console
+ $ sudo modprobe configfs
+ $ sudo insmod dtbocfg.ko
+ $ sudo mkdir /sys/kernel/config/device-tree/overlays/accesstest
+ $ sudo dtc -O dtb -o /sys/kernel/config/device-tree/overlays/accesstest/dtbo accesstest-uio.dts
+ $ sudo bash -c "echo 1 > /sys/kernel/config/device-tree/overlays/accesstest/status"
+ $ ls /dev/uio*
+ /dev/uio0
+ $ sudo bash -c "echo 0 > /sys/kernel/config/device-tree/overlays/accesstest/status"
+ $ ls /dev/uio*
+ ls: cannot access '/dev/uio*': No such file or directory
+
+おお、自由自在!
+
+* dtbocfg.rb を使う [#l12bda56]
+
+ LANG:console
+ $ jed dtbocfg.rb
+ - CONFIG_OF_OVERLAY_PATH = "/config/device-tree/overlays/"
+ + CONFIG_PATH = "/sys/kernel/config/"
+ + CONFIG_OF_OVERLAY_PATH = "/sys/kernel/config/device-tree/overlays/"
+ + DTBOCFG_KO_PATH = File.join(File.expand_path(File.dirname(__FILE__)), 'dtbocfg.ko')
+ ...
+ def initialize(device_name)
+ + insmod unless File.exists? CONFIG_OF_OVERLAY_PATH
+ +
+ @device_name = device_name
+ @device_tree_overlay_path = CONFIG_OF_OVERLAY_PATH + device_name
+ @debug = false
+ end
+
+ + def insmod
+ + system "modprobe configfs" unless File.exists? CONFIG_PATH
+ + system "insmod #{DTBOCFG_KO_PATH}" unless File.exists? CONFIG_OF_OVERLAY_PATH
+ + end
+ +
+ def create
+ $ ruby
+ -bash: ruby: command not found
+ $ sudo apt install ruby
+ $ sudo ruby dtbocfg.rb --install accesstest -dts accesstest-uio.dts
+ $ ls /dev/uio*
+ /dev/uio0
+ $ sudo ruby dtbocfg.rb --stop accesstest
+ $ ls /dev/uio0
+ ls: cannot access '/dev/uio0': No such file or directory
+
+コマンド一発で直接 dts を読み込めて、とても便利
+
+* カーネルに含めてしまいたい? [#xaa1ba5a]
+
+modprobe や insmode をしたくなければカーネルに含めてしまえば良い
+
+configfs の modprobe が必要になるのは、
+カーネル設定でモジュールを選ぶ際に {M} としていたため。
+これを {*} にしたところ、modprobe configfs は必要なくなります。
+
+dtbocfg をカーネルモジュールとするには、~
+http://manual.atmark-techno.com/dist/atmark-dist_developers_guide_ja-1.0.7/ch11 ~
+のようにすればいいみたい。
+
+Makefile が黒魔術だ。
+
+後で調べる。
+* コメント・質問 [#ta227d68]
+
+#article_kcaptcha